package com.enterprise.service.impl;

import com.enterprise.dao.ResourcesDao;
import com.enterprise.dao.RespageDao;
import com.enterprise.dao.ServersManage;
import com.enterprise.entity.Resources;
import com.enterprise.entity.Respage;
import com.enterprise.entity.page.PageModel;
import com.enterprise.service.RespageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("respageService")
public class RespageServiceImpl extends ServersManage<Respage, RespageDao> implements RespageService {

	@Resource(name="respageDao")
	@Override
	public void setDao(RespageDao respageDao) {
		this.dao = respageDao;
	}

	@Autowired
	ResourcesDao resourcesDao;

	@Override
	public PageModel selectPowerPageList(Respage respage) {
		// 查询页面list
		PageModel pageModel = this.dao.selectPowerPageList(respage);
		List<Respage> list = pageModel.getList();
		// 存入按钮list
		for (Respage page:list) {
			List<Resources> resourcesList = resourcesDao.getResourcesByPageId(Long.valueOf(page.getPageid()),respage.getRoleid());
			page.setResourcesList(resourcesList);
		}
		return pageModel;
	}
}
